<!DOCTYPE html>
<html lang="zh-cn">
<head>
{include file="public/header" /}
</head>
<style>
.error{
  color:red;
}
</style>
<body>
<div class="panel admin-panel">
  <div class="body-content">
    <form method="post" class="form-x" action="" id="form-admin-add" name="form-admin-add" action="">
      <div class="form-group">
        <div class="label">
          <label for="sitename">管理员帐号：</label>
        </div>
        <div class="field">
          <label style="line-height:33px;">
           <span><?php echo session('name'); ?></span>
          </label>
        </div>
      </div>     
      <div class="form-group">
        <div class="label">
          <label for="sitename">新密码：</label>
        </div>
        <div class="field">
          <input type="password" class="input w50" name="newpass" id="newpass" size="50" minlength />         
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label for="sitename">确认新密码：</label>
        </div>
        <div class="field">
          <input type="password" class="input w50" name="renewpass" id="renewpass" size="50" minlength />          
        </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <input  class="button bg-main" type="submit" value="提交" />  
        </div>
      </div>      
    </form>
  </div>
</div>
<script type="text/javascript">

    $(function () {
        //判断密码是否输入。和2次密码是否一致
        $("#form-admin-add").validate({
          rules: {
                newpass: {
                    required: true,
                    minlength:5,
                },
                renewpass: {
                    required: true,
                    minlength:5,
                    equalTo: "#newpass"
                },
            },
            messages: {
              newpass: {
                required: "请输入密码",
                minlength: "密码长度不能小于 5 个字母"
              },
              renewpass: {
                required: "请输入密码",
                minlength: "密码长度不能小于 5 个字母",
                equalTo: "两次密码输入不一致"
              },
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            //submitHandler提交
            submitHandler: function (form) {
                var password = $('#newpass').val();//取得输入的新密码
                $.ajax({
                    type:'POST',
                    url:"{:url('houtai/admin/editajax')}",
                    data:{
                      'id':1,
                       'password':password,
                    },
                    success:function(data){
                        //判断回调staus状态。
                        var data=eval("("+data+")");
                        if (data.status){
                            parent.layer.msg('修改密码成功~！',{icon:1,time:1000,},function(){parent.location.reload();});
                        }else{
                            parent.layer.msg('修改密码失败~！',{icon:2,time:1000,});
                        }
                    },
                });
            }
        });
    });
</script>
</body>
</html>